package com.reactim.user.entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

/**
 * 好友分组实体类
 */
@Data
@Entity
@Table(name = "friend_groups",
       indexes = {
           @Index(name = "idx_user_id", columnList = "userId"),
           @Index(name = "idx_user_sort", columnList = "userId, sortOrder")
       })
@EntityListeners(AuditingEntityListener.class)
@EqualsAndHashCode(callSuper = false)
public class FriendGroup {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @Column(nullable = false)
    private Long userId; // 分组所属用户ID
    
    @Column(nullable = false, length = 50)
    private String name; // 分组名称
    
    @Column(length = 200)
    private String description; // 分组描述
    
    @Column(nullable = false)
    private Integer sortOrder = 0; // 排序顺序
    
    @Column(nullable = false)
    private Boolean isDefault = false; // 是否为默认分组
    
    @Column(nullable = false)
    private Boolean isSystem = false; // 是否为系统分组
    
    @CreatedDate
    @Column(nullable = false, updatable = false)
    private LocalDateTime createdAt;
    
    @LastModifiedDate
    @Column(nullable = false)
    private LocalDateTime updatedAt;
}